package net.sf.jimex.jira;

import com.atlassian.jira.issue.IssueFieldConstants;

import java.util.Map;
import java.util.Vector;

/**
 * andrew 16.02.2006 22:05:12
 */
public class IssueHelper {
    private static final String CREATED = IssueFieldConstants.CREATED;
    public static final String SUMMARY = IssueFieldConstants.SUMMARY;
    public static final String TYPE = "type";
    private static final String RESOLUTION = IssueFieldConstants.RESOLUTION;
    private static final String STATUS = IssueFieldConstants.STATUS;
    private static final String KEY = "key";
    private static final String AFFECTS_VERSIONS = "affectsVersions";
    private static final String UPDATED = IssueFieldConstants.UPDATED;
    private static final String ID = "id";
    private static final String COMPONENTS = IssueFieldConstants.COMPONENTS;
    private static final String FIX_VERSIONS = IssueFieldConstants.FIX_FOR_VERSIONS;
    private static final String CUSTOM_FIELDS_VALUES = "customFieldsValues";
    public static final String DESCRIPTION = IssueFieldConstants.DESCRIPTION;
    private static final String REPORTER = IssueFieldConstants.REPORTER;
    private static final String VOTES = IssueFieldConstants.VOTES;
    public static final String ASSIGNEE = IssueFieldConstants.ASSIGNEE;
    public static String PROJECT = IssueFieldConstants.PROJECT;
    public static String ESTIMATED = IssueFieldConstants.TIME_ESTIMATE;
    public static final String ISSUE_PARENT_ID = "parentIssueKey";
    public static final int SUBTASK_TYPE = -1;
    public static final String PROJECT_LEAD = "lead";
    public static final String PROJECT_NAME = "name";

    public static String getCreated(Map issueMap) {
        return getValueAsString(issueMap, CREATED);
    }

    public static String getSummary(Map issueMap) {
        return getValueAsString(issueMap, SUMMARY);
    }

    public static String getType(Map issueMap) {
        return getValueAsString(issueMap, TYPE);
    }

    public static String getResolution(Map issueMap) {
        return getValueAsString(issueMap, RESOLUTION);
    }

    public static String getStatus(Map issueMap) {
        return getValueAsString(issueMap, STATUS);
    }

    public static String getKey(Map issueMap) {
        return getValueAsString(issueMap, KEY);
    }

    public static Vector getAffectsVersions(Map issueMap) {
        return getValueAsVector(issueMap, AFFECTS_VERSIONS);
    }


    public static String getUpdated(Map issueMap) {
        return getValueAsString(issueMap, UPDATED);
    }

    public static String getId(Map issueMap) {
        return getValueAsString(issueMap, ID);
    }

    public static Vector getComponents(Map issueMap) {
        return getValueAsVector(issueMap, COMPONENTS);
    }

    public static Vector getFixVersions(Map issueMap) {
        return getValueAsVector(issueMap, FIX_VERSIONS);
    }

    public static Vector getCustomFieldsValues(Map issueMap) {
        return getValueAsVector(issueMap, CUSTOM_FIELDS_VALUES);
    }

    public static String getDescription(Map issueMap) {
        return getValueAsString(issueMap, DESCRIPTION);
    }

    public static String getReporter(Map issueMap) {
        return getValueAsString(issueMap, REPORTER);
    }

    public static String getVotes(Map issueMap) {
        return getValueAsString(issueMap, VOTES);
    }

    public static String getAssignee(Map issueMap) {
        return getValueAsString(issueMap, ASSIGNEE);
    }

    private static String getValueAsString(Map issueMap, String key) {
        String result = (String) issueMap.get(key);
        return result;
    }

    private static Vector getValueAsVector(Map issueMap, String key) {
        Vector result = (Vector) issueMap.get(key);
        return result;
    }


}
